1
- PROJECTFOLDER =fsqlf
1
+ PRJNAME =fsqlf
2
2
3
3
CFLAGS+=-std =c99
4
4
CFLAGS+ =-Wall
@@ -10,9 +10,12 @@ CXXFLAGS+=-DVERSION=\"$(VERSION)\"
10
10
CXXFLAGS+ =-Iinclude
11
11
12
12
ifdef WIN
13
+ BLD=builds/windows
13
14
OS_TARGET=windows
14
- EXEC_CLI=fsqlf.exe
15
- EXEC_GUI=wx_fsqlf.exe
15
+ EXEC_CLI=$(BLD)/fsqlf.exe
16
+ EXEC_GUI=$(BLD)/wx_fsqlf.exe
17
+ UTIL_TXT2H=$(BLD)/text_to_header.exe
18
+ CFLAGS+=-DBUILDING_LIBFSQLF
16
19
# i686
17
20
# https://myonlineusb.wordpress.com/2011/06/08/what-is-the-difference-between-i386-i486-i586-i686-i786/
18
21
# CC=i586-mingw32msvc-gcc
@@ -26,10 +29,12 @@ ifdef WIN
26
29
# Option "-mthreads" needs to be removed, so mingwm10.dll would not be needed
27
30
# (http://old.nabble.com/mingwm10.dll-ts8920679.html)
28
31
else
32
+ BLD=builds/linux
29
33
OS_TARGET=linux
30
34
PREFIX=/usr/local
31
- EXEC_CLI=fsqlf
32
- EXEC_GUI=wx_fsqlf
35
+ EXEC_CLI=$(BLD)/fsqlf
36
+ EXEC_GUI=$(BLD)/wx_fsqlf
37
+ UTIL_TXT2H=$(BLD)/text_to_header
33
38
CC=gcc
34
39
CXX=g++
35
40
CXXFLAGS+= `wx-config --cxxflags`
@@ -41,99 +46,101 @@ else
41
46
endif
42
47
endif
43
48
44
-
45
-
46
49
ifeq (Darwin, ${_system_type})
47
- LIBNAME=libfsqlf.dylib
50
+ LIBNAME=$(BLD)/ libfsqlf.dylib
48
51
LIBFLAGS=-dynamiclib
49
52
else
50
53
ifdef WIN
51
- LIBNAME=libfsqlf.dll
54
+ LIBNAME=$(BLD)/ libfsqlf.dll
52
55
LIBFLAGS=-shared -Wl,--out-implib,libfsqlf.a
53
56
else
54
- LIBNAME=libfsqlf.so
57
+ LIBNAME=$(BLD)/ libfsqlf.so
55
58
LIBFLAGS=-shared
56
59
endif
57
60
endif
58
61
59
62
60
- .PHONY : all clean zip test test-print test-gold clean_obj clean_test install uninstall
63
+
64
+ .PHONY : all clean zip test install uninstall
61
65
62
66
63
67
64
- all : $(EXEC_CLI ) $(EXEC_GUI )
68
+ all : $(EXEC_CLI ) $(EXEC_GUI )
65
69
66
70
67
71
68
72
#
69
73
# BUILD LIB
70
74
#
71
- LCOBJ += lib_fsqlf/conf_file/conf_file_create.o
72
- LCOBJ += lib_fsqlf/conf_file/conf_file_read.o
73
- LCOBJ += lib_fsqlf/formatter/lex.yy.o
74
- LCOBJ += lib_fsqlf/formatter/lex_wrapper.o
75
- LCOBJ += lib_fsqlf/formatter/print_keywords.o
76
- LCOBJ += lib_fsqlf/formatter/tokque.o
77
- LCOBJ += lib_fsqlf/kw/kw.o
78
- LCOBJ += lib_fsqlf/kw/kwmap.o
79
- LCOBJ += lib_fsqlf/lex/token.o
80
- LCOBJ += utils/queue/queue.o
81
- LCOBJ += utils/stack/stack.o
82
- LCOBJ += utils/string/read_int.o
83
-
84
- $(LCOBJ ) : % .o: % .c
85
- $(CC ) $(CFLAGS ) -c $< -o $@
86
-
87
- $(filter lib_fsqlf/% ,$(LCOBJ ) ) : % .o: % .c include/lib_fsqlf.h
88
-
89
- $(LIBNAME ) : $(LCOBJ )
90
- $(CC ) $(CFLAGS ) $(LIBFLAGS ) $^ -o $@
91
-
92
- lib_fsqlf/conf_file/conf_file_read.o : utils/string/read_int.h
93
- lib_fsqlf/formatter/lex_wrapper.o : lib_fsqlf/formatter/lex.yy.h
94
- lib_fsqlf/formatter/lex.yy.h : lib_fsqlf/formatter/lex.yy.c
95
- lib_fsqlf/formatter/lex.yy.c : lib_fsqlf/formatter/fsqlf.lex lib_fsqlf/formatter/print_keywords.h
75
+ LCOBJ += $(BLD ) /lib_fsqlf/conf_file/conf_file_create.o
76
+ LCOBJ += $(BLD ) /lib_fsqlf/conf_file/conf_file_read.o
77
+ LCOBJ += $(BLD ) /lib_fsqlf/formatter/lex_wrapper.o
78
+ LCOBJ += $(BLD ) /lib_fsqlf/formatter/print_keywords.o
79
+ LCOBJ += $(BLD ) /lib_fsqlf/formatter/tokque.o
80
+ LCOBJ += $(BLD ) /lib_fsqlf/kw/kw.o
81
+ LCOBJ += $(BLD ) /lib_fsqlf/kw/kwmap.o
82
+ LCOBJ += $(BLD ) /lib_fsqlf/lex/token.o
83
+ LCOBJ += $(BLD ) /utils/queue/queue.o
84
+ LCOBJ += $(BLD ) /utils/stack/stack.o
85
+ LCOBJ += $(BLD ) /utils/string/read_int.o
86
+ BLDDIRS += $(dir $(LCOBJ ) )
87
+
88
+ $(LCOBJ ) : $(BLD ) /% .o: ./% .c | $(BLDDIRS )
89
+ $(CC ) -o $@ -c $< $(CFLAGS ) -I$(BLD ) -Ilib_fsqlf/formatter
90
+ $(BLD ) /lex.yy.o : $(BLD ) /lex.yy.c
91
+ $(CC ) -o $@ -c $< $(CFLAGS ) -Ilib_fsqlf/formatter
92
+
93
+ $(filter lib_fsqlf/% ,$(LCOBJ ) ) : $(BLDP ) % .o: ./% .c include/lib_fsqlf.h
94
+
95
+ $(LIBNAME ) : $(LCOBJ ) $(BLD ) /lex.yy.o
96
+ $(CC ) -o $@ $^ $(CFLAGS ) $(LIBFLAGS )
97
+
98
+ $(BLD ) /lib_fsqlf/conf_file/conf_file_read.o : utils/string/read_int.h
99
+ $(BLD ) /lib_fsqlf/formatter/lex_wrapper.o : $(BLD ) /lex.yy.h
100
+ $(BLD ) /lex.yy.h : $(BLD ) /lex.yy.c
101
+ $(BLD ) /lex.yy.c : lib_fsqlf/formatter/fsqlf.lex lib_fsqlf/formatter/print_keywords.h
96
102
# flex options (e.g. `-o`) has to be before input file
97
- flex -o $@ --header-file=lib_fsqlf/formatter /lex.yy.h $<
103
+ flex -o $@ --header-file=$( BLD ) /lex.yy.h $<
98
104
99
105
100
106
101
107
#
102
108
# BUILD CLI
103
109
#
104
- COBJ += cli/main.o
105
- COBJ += cli/cli.o
110
+ COBJ += $(BLD ) /cli/main.o
111
+ COBJ += $(BLD ) /cli/cli.o
112
+ BLDDIRS += $(dir $(COBJ ) )
106
113
107
- $(COBJ ) : % .o: % .c include/lib_fsqlf.h
108
- $(CC ) $( CFLAGS ) -c $< -o $@
114
+ $(COBJ ) : $( BLD ) / % .o: ./ % .c include/lib_fsqlf.h | $( BLDDIRS )
115
+ $(CC ) -o $@ -c $< $( CFLAGS )
109
116
110
- $( EXEC_CLI ) : $( COBJ ) $(LIBNAME )
111
- $( CC ) $(CFLAGS ) $( COBJ ) -L. -lfsqlf -Wl,-rpath,. -o $@
112
- # strip $@
117
+ INTUTIL = $(BLD ) /utils/string/read_int.o
118
+ $( EXEC_CLI ) : $(COBJ ) $( INTUTIL ) $( LIBNAME )
119
+ $( CC ) -o $@ $( CFLAGS ) $( COBJ ) $( INTUTIL ) -L $( BLD ) -lfsqlf -Wl,-rpath,.
113
120
114
121
115
122
116
123
#
117
124
# BUILD GUI
118
125
#
119
- $(EXEC_GUI ) : wx_fsqlf.o basic_notepad.o dnd_target.o $(LIBNAME )
120
- $(CXX ) $^ -o $@ $(CXXFLAGS ) $(LDFLAGS ) -L. -lfsqlf -Wl,-rpath,.
121
- strip $@
126
+ CXXOBJ += $(BLD ) /gui/wx_fsqlf.o
127
+ CXXOBJ += $(BLD ) /gui/basic_notepad.o
128
+ CXXOBJ += $(BLD ) /gui/dnd_target.o
129
+ BLDDIRS += $(dir $(CXXOBJ ) )
122
130
123
- # generic rule for C++ building
124
- CXXOBJ = wx_fsqlf.o basic_notepad.o dnd_target.o
131
+ $( CXXOBJ ) : $( BLD ) / % .o: ./ % .cpp ./ % .hpp | $( BLDDIRS )
132
+ $( CXX ) -o $@ -c $< $( CXXFLAGS ) -I $( BLD )
125
133
126
- $(CXXOBJ ) : % .o: gui/ % .cpp gui/ % .hpp
127
- $(CXX ) -c $< - o $@ $(CXXFLAGS )
134
+ $(EXEC_GUI ) : $( CXXOBJ ) $( LIBNAME )
135
+ $(CXX ) - o $@ $^ $(CXXFLAGS ) $( LDFLAGS ) -L $( BLD ) -lfsqlf -Wl,-rpath,.
128
136
129
- wx_fsqlf.o : gui/basic_notepad.hpp
130
- basic_notepad.o : gui/dnd_target.hpp gui /license_text.h
137
+ $( BLD ) /gui/ wx_fsqlf.o : gui/basic_notepad.hpp
138
+ $( BLD ) /gui/ basic_notepad.o : gui/dnd_target.hpp $( BLD ) /license_text.h
131
139
132
- gui/license_text.h : LICENSE text_to_header
133
- ./text_to_header $< $@ LICENSE_TEXT
134
-
135
- text_to_header : utils/text_to_header/text_to_header.c
136
- $(CC ) $(CFLAGS ) $< -o $@
140
+ $(UTIL_TXT2H ) : utils/text_to_header/text_to_header.c
141
+ $(CC ) -o $@ $< $(CFLAGS )
142
+ $(BLD ) /license_text.h : LICENSE $(UTIL_TXT2H )
143
+ $(UTIL_TXT2H ) $< $@ LICENSE_TEXT
137
144
138
145
139
146
@@ -144,71 +151,66 @@ text_to_header: utils/text_to_header/text_to_header.c
144
151
# Given certain input to `fsqlf`, actual output (lead) is compared
145
152
# against to it's predefined expected output (gold).
146
153
# TF stands for "test file".
147
- test : test-format-files
148
-
149
- test-format-files : $( EXEC_CLI ) tests/format_files_test
150
- cd tests && ./format_files_test
154
+ TSTOBJ += $( BLD ) /tests/tools/file_compare.o
155
+ TSTOBJ += $( BLD ) /tests/format_files_test.o
156
+ BLDDIRS += $( dir $( TSTOBJ ) )
157
+ BLDDIRS += $( BLD ) /tests/cases
151
158
152
- tests/tools/file_compare.o : tests/tools/file_compare.c
153
- $(CC ) $( CFLAGS ) -c $< -o $@
159
+ test : $( EXEC_CLI ) $( BLD ) / tests/format_files_test
160
+ $(BLD ) /tests/format_files_test
154
161
155
- tests/format_files_test.o : tests/format_files_test.c
156
- $(CC ) $(CFLAGS ) -c $< -o $@
162
+ $(TSTOBJ ) : $(BLD ) /% .o: ./% .c | $(BLDDIRS )
163
+ $(CC ) -o $@ -c $< $(CFLAGS ) \
164
+ -D PATH_FSQLF_CLI=\" $(EXEC_CLI ) \" \
165
+ -D PATH_FSQLF_LIB=\" $(BLD ) \" \
166
+ -D PATH_TC_STATICSQL=\" tests/cases/\" \
167
+ -D PATH_TC_GENERATED=\" $(BLD ) /tests/cases/\"
157
168
158
- tests/format_files_test : tests/format_files_test.o tests/tools/file_compare.o
159
- $(CC ) $( CFLAGS ) $^ -o $@
169
+ $( BLD ) / tests/format_files_test : $( TSTOBJ )
170
+ $(CC ) -o $@ $^ $( CFLAGS )
160
171
161
172
162
173
163
174
#
164
- # CLEANUP
175
+ # OUT OF SOURCE BUILD FOLDERS
165
176
#
166
- TMP_BAKUPS =$(wildcard * /* ~) $(wildcard * ~) $(TEST_TMP_ORIGINAL ) $(TEST_TMP_FORMATED )
177
+ $(sort $(BLDDIRS ) ) :
178
+ mkdir -p $@
167
179
168
- clean : clean_local clean_win clean_obj clean_test
169
180
170
- clean_local :
171
- rm -R -f $(EXEC_GUI ) $(EXEC_CLI ) lib_fsqlf/formatter/lex.yy.c $(TMP_BAKUPS ) \
172
- lib_fsqlf/formatter/lex.yy.h \
173
- $(LIBNAME ) libfsqlf.a \
174
- $(wildcard $(PROJECTFOLDER ) * .zip) tmp gui/license_text.h $(CONF_FILE ) \
175
- text_to_header builds
176
- make clean_obj
177
181
178
- clean_win :
179
- make clean_local WIN=1
180
-
181
- clean_obj :
182
- rm -f * .o lib_fsqlf/* .o lib_fsqlf/* /* .o utils/* /* .o cli/* .o
183
-
184
- clean_test :
185
- rm -f tests/format_files_test tests/* .o tests/tools/* .o tests/cases/* _actual.sql
182
+ #
183
+ # CLEANUP
184
+ #
185
+ clean :
186
+ rm -f -R builds/
186
187
187
188
188
189
189
190
#
190
191
# BUILD ARCHIVE (source and binaries for publishing)
191
192
#
192
193
formatting.conf : lib_fsqlf/kw/kwmap_defaults.def $(EXEC_CLI )
193
- ./$(EXEC_CLI ) --create-config-file
194
+ LD_LIBRARY_PATH= $( BLD ) ./$(EXEC_CLI ) --create-config-file
194
195
195
196
VERSION: =$(shell git describe master)
196
- ZIP_NAME: =$(PROJECTFOLDER ) .$(VERSION ) .zip
197
+ PKGAREA: =builds/packaging
198
+ ZIP_NAME: =$(PKGAREA ) /$(PRJNAME ) .$(VERSION ) .zip
197
199
198
200
zip : tmp_folder
199
201
rm -f $(ZIP_NAME )
200
- git archive master -o $(ZIP_NAME ) --format=zip --prefix=' $(PROJECTFOLDER )/source/'
201
- cd tmp/ && zip -r ../ $(ZIP_NAME ) $( PROJECTFOLDER )
202
+ git archive master -o $(ZIP_NAME ) --format=zip --prefix=' $(PRJNAME )/source/'
203
+ zip -r $(ZIP_NAME ) $( PKGAREA ) / $( PRJNAME )
202
204
203
205
tmp_folder : LICENSE README.md
204
206
make prep_bin
205
- make clean_obj # to ensure that object files are for needed OS
206
207
make prep_bin WIN=1
207
- cp -t tmp /$(PROJECTFOLDER ) $^
208
+ cp -t $( PKGAREA ) /$(PRJNAME ) $^
208
209
209
210
prep_bin : $(EXEC_CLI ) $(EXEC_GUI ) $(LIBNAME ) formatting.conf
210
- mkdir -p tmp/$(PROJECTFOLDER ) /$(OS_TARGET )
211
- cp -t tmp/$(PROJECTFOLDER ) /$(OS_TARGET ) $^
211
+ rm -Rf $(PKGAREA ) /$(PRJNAME ) /$(OS_TARGET )
212
+ mkdir -p $(PKGAREA ) /$(PRJNAME ) /$(OS_TARGET )
213
+ cp -t $(PKGAREA ) /$(PRJNAME ) /$(OS_TARGET ) $^
212
214
213
215
214
216
0 commit comments