-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.mingw
126 lines (110 loc) · 3.59 KB
/
Makefile.mingw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#
# The Makefile of the slib
#
# Copyright (C) 2017-2020 Zhang Maiyun
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# This file is part of the slib.
# The slib is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CROSS=
CC=$(CROSS)gcc
AR=$(CROSS)ar
RM=rm
CFLAGS=-W -Wall -pedantic -O2 -Iinclude
PREFIX=C:/Program Files/libsbl
CFILES= \
src/astro.c \
src/astro2.c \
src/bsearchfile.c \
src/colorprintf.c \
src/eular.c \
src/fnmatch.c \
src/fsize.c \
src/gcf.c \
src/getch.c \
src/getopt.c \
src/ispn.c \
src/isrp.c \
src/itoa.c \
src/lcm.c \
src/mret.c \
src/permcomb.c \
src/pnlst.c \
src/prtpn.c \
src/sleepS.c \
src/splitpathS.c \
src/stack.c \
src/timedate.c \
src/timedat2.c
HFILES= \
include/slib/astro.h \
include/slib/fileopt.h \
include/slib/fnmatch.h \
include/slib/general.h \
include/slib/getopt.h \
include/slib/itoa.h \
include/slib/math.h \
include/slib/overflow.h \
include/slib/stack.h \
include/slib/timedate.h \
include/slib.h
SOSUF=.dll
EXESUF=.exe
SOFLAGS=-shared
LIBDIR=$(PREFIX)/lib
BINDIR=$(PREFIX)/bin
INCLUDEDIR=$(PREFIX)/include
.PHONY: install clean all tags
all:libsbl$(SOSUF) sbltool$(EXESUF)
libsbl$(SOSUF): $(CFILES:.c=.o)
$(CC) $(SOFLAGS) src/*.o -o $@
$(AR) rcs ./libsbl.a src/*.o
sbltool$(EXESUF): libsbl$(SOSUF) sbltool.c
$(CC) $(CFLAGS) -o $@ sbltool.c -L. -lsbl
%.o:%.c $(HFILES)
$(CC) $(CFLAGS) -c $< -o $@
install:
install -c -d -m 755 $(LIBDIR) $(INCLUDEDIR) $(INCLUDEDIR)/slib
install -c -p -m 644 include/slib.h $(INCLUDEDIR)
install -c -p -m 644 include/slib $(INCLUDEDIR)
install -c -p -m 644 libsbl.a $(LIBDIR)
install -c -p -m 755 libsbl$(SOSUF) $(LIBDIR)
install -c -p -m 755 sbltool${EXESUF} ${BINDIR}
clean:
-$(RM) -f *.o *.obj
cd src
-$(RM) -f *.o *.obj
cd ..
cd test
-$(RM) -f *.o *.obj
cd ..
-$(RM) -f libsbl.dll libsbl.*so* sbltool.exe sbltool *.o */*.o *.a libsbl.bc libsbl.js libsbl.wasm
tags:
ctags -R
distclean: clean
libsbl.bc: $(CFILES:.c=.o)
$(CC) -o libsbl.bc $(CFILES:.c=.o)
DELETE_ON_ERROR:
exp.txt: libsbl.bc
nm -defined-only libsbl.bc | grep T | cut -f3 -d' ' | sed "s/^/'_/;s/$$/',/" | tr '\n' ' ' | sed 's/..$$//' > exp.txt
libsbl.js: exp.txt
$(CC) -o libsbl.js -O3 --memory-init-file 0 -s WASM=0 -s ENVIRONMENT=web -s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap']" -s EXPORTED_FUNCTIONS="[$$(cat exp.txt)]" libsbl.bc
rm exp.txt
wxlibsbl.js: libsbl.bc
$(CC) -o wxlibsbl.js -O3 --memory-init-file 0 -s WASM=0 -s ENVIRONMENT=shell -s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap', 'getValue', 'setValue']" -s EXPORTED_FUNCTIONS="['_slib_combi','_slib_d2dn','_slib_deg2rad','_slib_eular','_slib_factorial','_slib_gcf','_slib_h2hms','_slib_hms2h','_slib_ispn','_slib_isrp','_slib_jd2tm','_slib_lcm','_slib_permu','_slib_pnlst','_slib_rad2deg','_slib_sf_sunrise','_slib_sun_decl_by_date','_slib_tm2jd', '_malloc', '_free']" libsbl.bc
echo "module.exports=Module;">>wxlibsbl.js