Changes in uspace/Makefile.common [e6ae77a:9c14309] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile.common
re6ae77a r9c14309 44 44 # EXTRA_CLEAN additional cleanup targets 45 45 # 46 # MATH set to 'y' to use the math library 47 # POSIX_COMPAT set to 'y' to use POSIX compatibility layer 48 # 46 49 # Optionally, for a binary: 47 50 # STATIC_NEEDED set to 'y' for init binaries, will build statically … … 50 53 # (e.g. uses thread-local variables) 51 54 # 52 # Optionally, for a lib rary:53 # S OVERSION shared library version (major.minor),54 # if missing, no shared library is built55 # Optionally, for a libary: 56 # SLIBRARY Name with full version, e.g. libfoo.so.0.0 57 # LSONAME Soname / name with short version, e.g. libfoo.so.0 55 58 # 56 59 # (x) required variables … … 72 75 -include $(CONFIG_MAKEFILE) 73 76 74 OUTPUTS = $(EXTRA_OUTPUT)75 76 77 ifneq ($(BINARY),) 77 78 JOB = $(BINARY).job 79 OUTPUT = $(BINARY) 78 80 TEST_BINARY = test-$(BINARY) 79 OUTPUTS += $(BINARY)$(BINARY).disasm81 EXTRA_OUTPUT += $(BINARY).disasm 80 82 EXTRA_CLEAN += $(BINARY).map 81 83 endif … … 83 85 ifneq ($(LIBRARY),) 84 86 JOB = $(LIBRARY).job 87 OUTPUT = $(LIBRARY).a 85 88 TEST_BINARY = test-$(LIBRARY) 86 OUTPUTS += $(LIBRARY).a87 89 endif 88 90 89 91 ifeq ($(CONFIG_BUILD_SHARED_LIBS),y) 90 ifneq ($(SOVERSION),) 91 SLIBRARY = $(LIBRARY).so.$(SOVERSION) 92 LSONAME = $(LIBRARY).so.$(basename $(SOVERSION)) 93 OUTPUTS += $(SLIBRARY) $(SLIBRARY).disasm $(LSONAME) 94 EXTRA_CLEAN += $(LIBRARY).la $(SLIBRARY).map 92 ifneq ($(SLIBRARY),) 93 LARCHIVE = $(LIBRARY).la 94 LOUTPUT = $(SLIBRARY) 95 EXTRA_OUTPUT += $(LOUTPUT).disasm $(LIBRARY).so $(LSONAME) 96 EXTRA_CLEAN += $(LOUTPUT).map $(LOUTPUT).ldisasm \ 97 $(LIBC_PREFIX)/shared/arch/$(UARCH)/_lib.ld \ 98 $(LIBRARY).so $(LSONAME) 95 99 endif 96 100 endif … … 112 116 113 117 LIBPOSIX_PREFIX = $(LIB_PREFIX)/posix 118 119 LIBCRYPTO_PREFIX = $(LIB_PREFIX)/crypto 120 LIBBLOCK_PREFIX = $(LIB_PREFIX)/block 121 LIBFDISK_PREFIX = $(LIB_PREFIX)/fdisk 122 LIBLABEL_PREFIX = $(LIB_PREFIX)/label 123 LIBFS_PREFIX = $(LIB_PREFIX)/fs 124 LIBCLUI_PREFIX = $(LIB_PREFIX)/clui 125 LIBFMTUTIL_PREFIX = $(LIB_PREFIX)/fmtutil 126 127 LIBGRAPH_PREFIX = $(LIB_PREFIX)/graph 128 LIBSOFTREND_PREFIX = $(LIB_PREFIX)/softrend 129 LIBDRAW_PREFIX = $(LIB_PREFIX)/draw 130 LIBGUI_PREFIX = $(LIB_PREFIX)/gui 131 132 LIBEXT4_PREFIX = $(LIB_PREFIX)/ext4 133 134 LIBUSB_PREFIX = $(LIB_PREFIX)/usb 135 LIBUSBHOST_PREFIX = $(LIB_PREFIX)/usbhost 136 LIBUSBDEV_PREFIX = $(LIB_PREFIX)/usbdev 137 LIBUSBHID_PREFIX = $(LIB_PREFIX)/usbhid 138 LIBUSBVIRT_PREFIX = $(LIB_PREFIX)/usbvirt 139 140 LIBDRV_PREFIX = $(LIB_PREFIX)/drv 141 LIBHOUND_PREFIX = $(LIB_PREFIX)/hound 142 LIBPCM_PREFIX = $(LIB_PREFIX)/pcm 143 LIBNIC_PREFIX = $(LIB_PREFIX)/nic 144 LIBIEEE80211_PREFIX = $(LIB_PREFIX)/ieee80211 145 LIBMINIX_PREFIX = $(LIB_PREFIX)/minix 146 LIBCOMPRESS_PREFIX = $(LIB_PREFIX)/compress 114 147 LIBDLTEST_PREFIX = $(LIB_PREFIX)/dltest 115 148 116 AFLAGS = --fatal-warnings 117 LFLAGS = --fatal-warnings --warn-common 149 LIBSCSI_PREFIX = $(LIB_PREFIX)/scsi 150 LIBTRACKMOD_PREFIX = $(LIB_PREFIX)/trackmod 151 152 LIBBITHENGE_PREFIX = $(LIB_PREFIX)/bithenge 153 154 LIBHTTP_PREFIX = $(LIB_PREFIX)/http 155 LIBURI_PREFIX = $(LIB_PREFIX)/uri 156 157 LIBNETTL_PREFIX = $(LIB_PREFIX)/nettl 158 159 AFLAGS = 160 LFLAGS = --fatal-warnings 161 162 # FIXME: This condition is a workaround for issues #692 and #693. 163 ifneq ($(KARCH),ia64) 164 ifneq ($(KARCH),mips32) 165 AFLAGS += --fatal-warnings 166 endif 167 endif 118 168 119 169 ifeq ($(STATIC_NEEDED),y) … … 132 182 133 183 ifeq ($(STATIC_BUILD),y) 134 BASE_LIBS = $(LIBC_PREFIX)/libc.a 135 else 136 BASE_LIBS = $(LIBC_PREFIX)/libc.so.0 184 BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a 185 ifeq ($(MATH),y) 186 BASE_LIBS += $(LIBMATH_PREFIX)/libmath.a 187 endif 188 else 189 BASE_LIBS = $(LIBC_PREFIX)/libc.so.0 $(LIBSOFTINT_PREFIX)/libsoftint.so.0 137 190 LINK_DYNAMIC = y 138 endif 139 140 BASE_LIBS += $(LIBSOFTFLOAT_PREFIX)/libsoftfloat.a $(LIBSOFTINT_PREFIX)/libsoftint.a 191 ifeq ($(MATH),y) 192 BASE_LIBS += $(LIBMATH_PREFIX)/libmath.so.0 193 endif 194 endif 141 195 142 196 ifeq ($(LINK_DYNAMIC),y) … … 147 201 endif 148 202 149 LIB_LINKER_SCRIPT = $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld 150 151 INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS) 152 153 ifneq ($(LIBRARY),) 154 INCLUDES_FLAGS += -Iinclude -I. 155 endif 156 157 INCLUDES_FLAGS += $(foreach lib,$(LIBS), -I$(LIB_PREFIX)/$(lib) -I$(LIB_PREFIX)/$(lib)/include) 158 159 # TODO: get rid of this special case 160 ifneq ($(filter math, $(LIBS)),) 161 INCLUDES_FLAGS += $(LIBMATH_INCLUDES_FLAGS) 203 ifeq ($(MATH),y) 204 INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS) $(LIBMATH_INCLUDES_FLAGS) 205 else 206 INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS) 162 207 endif 163 208 164 209 # PCUT-based unit tests 165 210 ifneq ($(TEST_SOURCES),) 166 TEST_OUTPUTS = $(TEST_BINARY) $(TEST_BINARY).disasm 211 TEST_OUTPUT = $(TEST_BINARY) 212 TEST_DISASM = $(TEST_BINARY).disasm 167 213 TEST_CFLAGS = -I$(LIB_PREFIX)/pcut/include -D__helenos__ 168 TEST_ BINARY_LIBS = $(LIB_PREFIX)/pcut/libpcut.a169 EXTRA_CLEAN += $(TEST_OUTPUT S) $(TEST_BINARY).map214 TEST_OUTPUT_LIBS = $(LIB_PREFIX)/pcut/libpcut.a 215 EXTRA_CLEAN += $(TEST_OUTPUT) $(TEST_OUTPUT).map $(TEST_DISASM) 170 216 ifneq ($(LIBRARY),) 171 TEST_BINARY_LIBS += $(LIBRARY).a 172 endif 173 TEST_BINARY_LIBS += $(TEST_LIBS) 174 endif 217 TEST_OUTPUT_LIBS += $(OUTPUT) 218 endif 219 TEST_OUTPUT_LIBS += $(TEST_LIBS) 220 endif 221 222 .PHONY: all clean depend 223 224 all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(LIBS) $(OUTPUT) $(LOUTPUT) $(EXTRA_OUTPUT) 225 226 all-test: $(TEST_OUTPUT) $(TEST_DISASM) 227 228 clean: 229 rm -f $(JOB) $(OUTPUT) $(LARCHIVE) $(LOUTPUT) $(EXTRA_OUTPUT) $(EXTRA_CLEAN) 230 find . -name '*.o' -follow -exec rm \{\} \; 231 find . -name '*.lo' -follow -exec rm \{\} \; 232 find . -name '*.d' -follow -exec rm \{\} \; 175 233 176 234 COMMON_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \ 177 235 -ffreestanding -fno-builtin -nostdlib -nostdinc -fexec-charset=UTF-8 \ 178 -finput-charset=UTF-8 -D__$(ENDIANESS)__ -fno-common \ 179 -fdebug-prefix-map=$(realpath $(ROOT_PATH))=. 236 -finput-charset=UTF-8 -D__$(ENDIANESS)__ 180 237 181 238 GCC_CFLAGS = -ffunction-sections -Wall -Wextra -Wno-clobbered \ … … 200 257 endif 201 258 259 # Prepare for POSIX before including platform specific stuff 260 ifeq ($(POSIX_COMPAT),y) 261 CFLAGS += -I$(LIBPOSIX_PREFIX)/include/posix -I$(LIBPOSIX_PREFIX)/include/ 262 BASE_LIBS = $(LIBPOSIX_PREFIX)/libposixaslibc.a $(LIBPOSIX_PREFIX)/libc4posix.a $(LIBSOFTINT_PREFIX)/libsoftint.a 263 endif 264 202 265 ## Setup platform configuration 203 266 # … … 208 271 # 209 272 210 ifeq ($(PRECHECK),y) 211 JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py 212 # XXX: Do not change the order of arguments. 213 CC_JOB = $(JOBFILE) $(JOB) $(CC) $< -o $@ 214 else 215 CC_JOB = $(CC) $< -o $@ 216 endif 273 JOBFILE = $(LIBC_PREFIX)/../../../tools/jobfile.py 217 274 218 275 ifeq ($(COMPILER),clang) … … 222 279 endif 223 280 224 ifeq ($(CONFIG_STRIP_BINARIES),y)225 LFLAGS += --strip-all226 endif227 228 281 LIB_CFLAGS = $(CFLAGS) -fPIC 229 LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) 282 LIB_LFLAGS = $(LFLAGS) -shared -soname $(LSONAME) --whole-archive 230 283 231 284 AS_CFLAGS := $(addprefix -Xassembler ,$(AFLAGS)) … … 237 290 DEPENDS := $(addsuffix .d,$(basename $(SOURCES))) $(addsuffix .test.d,$(basename $(TEST_SOURCES))) 238 291 239 LIBTAGS := $(foreach lib,$(LIBS), $(USPACE_PREFIX)/lib/$(lib)/tag) 240 LIBARGS := $(addprefix -L$(USPACE_PREFIX)/lib/, $(LIBS)) $(addprefix -l, $(LIBS)) 241 242 .PHONY: all all-test clean fasterclean depend 243 244 all: tag $(OUTPUTS) 245 246 all-test: $(TEST_OUTPUTS) 247 248 clean: 249 rm -f $(JOB) $(OUTPUTS) $(EXTRA_CLEAN) tag deps.mk 250 find . -name '*.o' -follow -exec rm \{\} \; 251 find . -name '*.lo' -follow -exec rm \{\} \; 252 find . -name '*.d' -follow -exec rm \{\} \; 253 254 fasterclean: 255 rm -f $(JOB) $(OUTPUTS) $(EXTRA_CLEAN) tag deps.mk 256 257 depend: $(PRE_DEPEND) 258 259 # "Tag" files are used to force relink of binaries when dependencies get rebuilt, 260 # regardless of whether the dependency was linked statically or dynamically, 261 # or which version of a dynamic library was used. Prerequisites for this file 262 # are defined further down. 263 tag: 264 touch tag 265 266 # Generate inter-module make dependencies. 267 # This is needed to ensure correct build order of libraries and code depending on them. 268 deps.mk: Makefile 269 echo > $@.new 270 for lib in $(LIBS); do \ 271 echo "$(SELF_TARGET): lib/$$lib.build" >> $@.new; \ 272 done 273 mv -f $@.new $@ 274 275 %.disasm: % 292 -include $(DEPENDS) 293 294 ifneq ($(BINARY),) 295 $(BINARY).disasm: $(BINARY) 276 296 ifeq ($(CONFIG_LINE_DEBUG),y) 277 297 $(OBJDUMP) -d -S $< > $@ … … 280 300 endif 281 301 282 ifneq ($(BINARY),) 283 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBTAGS) $(BASE_LIBS) 284 $(LD) $(LFLAGS) -T $(LINKER_SCRIPT) -Map $@.map -o $@ $(OBJECTS) $(LIBARGS) $(BASE_LIBS) 285 endif 286 287 ifneq ($(TEST_BINARY),) 288 $(TEST_BINARY): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_BINARY_LIBS) $(LIBTAGS) $(BASE_LIBS) 289 $(LD) $(LFLAGS) -T $(LINKER_SCRIPT) -Map $@.map -o $@ $(TEST_OBJECTS) $(TEST_BINARY_LIBS) $(LIBARGS) $(BASE_LIBS) 302 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBS) $(BASE_LIBS) 303 $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(BINARY).map -o $(BINARY) $(OBJECTS) $(LIBS) $(BASE_LIBS) 304 ifeq ($(CONFIG_STRIP_BINARIES),y) 305 $(STRIP) $(BINARY) 306 endif 307 endif 308 309 ifneq ($(SLIBRARY),) 310 $(LOUTPUT).disasm: $(LOUTPUT) 311 ifeq ($(CONFIG_LINE_DEBUG),y) 312 $(OBJDUMP) -d -S $< > $@ 313 else 314 $(OBJDUMP) -d $< > $@ 315 endif 316 317 $(LOUTPUT): $(LARCHIVE) $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld 318 $(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link-shlib.ld $(LIB_LFLAGS) $(LARCHIVE) -o $@ -Map $(LOUTPUT).map 319 320 $(LIBRARY).so: 321 ln -s $(SLIBRARY) $@ 322 323 $(LSONAME): 324 ln -s $(SLIBRARY) $@ 290 325 endif 291 326 292 327 ifneq ($(LIBRARY),) 293 tag: $(LIBRARY).a294 295 328 $(LIBRARY).a: $(OBJECTS) 296 329 $(AR) rc $@ $(OBJECTS) 297 330 endif 298 331 299 ifneq ($(SLIBRARY),) 300 tag: $(SLIBRARY) 301 302 $(LIBRARY).la: $(LOBJECTS) 332 ifneq ($(LARCHIVE),) 333 $(LARCHIVE): $(LOBJECTS) 303 334 $(AR) rc $@ $(LOBJECTS) 304 305 $(SLIBRARY): $(LIB_LINKER_SCRIPT) $(LIBRARY).la 306 $(LD) $(LIB_LFLAGS) -T $(LIB_LINKER_SCRIPT) -Map $@.map -o $@ --whole-archive $(LIBRARY).la --no-whole-archive 307 308 $(LSONAME): 309 ln -s $(SLIBRARY) $@ 335 endif 336 337 ifneq ($(TEST_OUTPUT),) 338 $(TEST_OUTPUT): $(LINKER_SCRIPT) $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS) 339 $(LD) -n $(LFLAGS) -T $(LINKER_SCRIPT) -M -Map $(TEST_OUTPUT).map -o $@ $(TEST_OBJECTS) $(TEST_OUTPUT_LIBS) $(LIBS) $(BASE_LIBS) 340 ifeq ($(CONFIG_STRIP_BINARIES),y) 341 $(STRIP) $(TEST_OUTPUT) 342 endif 343 $(TEST_BINARY).disasm: $(TEST_BINARY) 344 ifeq ($(CONFIG_LINE_DEBUG),y) 345 $(OBJDUMP) -d -S $< > $@ 346 else 347 $(OBJDUMP) -d $< > $@ 348 endif 310 349 endif 311 350 312 351 %.o: %.S | depend 313 $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ 352 $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@ 353 ifeq ($(PRECHECK),y) 354 $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ 355 endif 314 356 315 357 %.o: %.s | depend 316 $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ 358 $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@ 359 ifeq ($(PRECHECK),y) 360 $(JOBFILE) $(JOB) $< $@ as asm 361 endif 317 362 318 363 %.o: %.c | depend 319 $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) 364 $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@ 365 ifeq ($(PRECHECK),y) 366 $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) 367 endif 320 368 321 369 %.test.o: %.c | depend 322 $(CC_JOB) -c -MD -MP $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS) 370 $(CC) -MD $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS) -c $< -o $@ 371 ifeq ($(PRECHECK),y) 372 $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) $(EXTRA_CFLAGS) $(TEST_CFLAGS) 373 endif 323 374 324 375 %.lo: %.S | depend 325 $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ 376 $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@ 377 ifeq ($(PRECHECK),y) 378 $(JOBFILE) $(JOB) $< $@ as asm/preproc $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -D__ASM__ 379 endif 326 380 327 381 %.lo: %.s | depend 328 $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ 382 $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) $(AS_CFLAGS) -D__ASM__ -c $< -o $@ 383 ifeq ($(PRECHECK),y) 384 $(JOBFILE) $(JOB) $< $@ as asm 385 endif 329 386 330 387 %.lo: %.c | depend 331 $(CC_JOB) -c -MD -MP $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) 332 333 -include $(DEPENDS) 334 388 $(CC) -MD $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@ 389 ifeq ($(PRECHECK),y) 390 $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(LIB_CFLAGS) $(EXTRA_CFLAGS) 391 endif 392 393 depend: $(PRE_DEPEND) 394 395 ## 396 # This explicit dependecy of the output binary on the object files seems to be 397 # necessary to prevent parallel build failures (GNU make bug #26893 ???). 398 $(OUTPUT): $(OBJECTS) 399 400 $(LARCHIVE): $(LOBJECTS)
Note:
See TracChangeset
for help on using the changeset viewer.