Fix loading of a kernel that was linked with ld 2.20 on x86_64.
[dragonfly.git] / sys / conf / kern.pre.mk
1 #
2 # This Makefile covers the top part of the MI kernel build instructions
3 #
4
5 # Can be overridden by makeoptions or /etc/make.conf
6 KERNEL?=        kernel
7
8 # build this target if none is specified on the command line
9 .MAIN:  all
10
11 # Set the platform and machine architectures
12 #
13 P=      ${MACHINE_PLATFORM}
14 M=      ${MACHINE_ARCH}
15
16 SIZE?=          size
17 OBJCOPY?=       objcopy
18
19 COPTFLAGS?=-O -pipe
20 #COPTFLAGS?=-O -fthread-jumps -fcse-follow-jumps -fcrossjumping -frerun-cse-after-loop -fno-guess-branch-probability --param min-crossjump-insns=1 -pipe
21 #COPTFLAGS?=-O -fcrossjumping -pipe
22 #COPTFLAGS?=-Os -fno-strict-aliasing -pipe
23 #COPTFLAGS?=-O2 -fno-strict-aliasing -pipe
24 .if !defined(NO_CPU_COPTFLAGS)
25 COPTFLAGS+= ${_CPUCFLAGS}
26 .endif
27 # don't use -I- so we can use proper source-relative locality for local 
28 # includes.
29 #
30 # -I.  - this is to access the opt_*.h and use_*.h header files generated
31 #        in the kernel build directory.
32 #
33 # -Iinclude
34 #       - this is used to access forwarding header files for
35 #         <machine/*.h> that exist in the cpu architecture but do not
36 #         exist in the platform (machine/) architecture.  This allows
37 #         the platform to trivially override the cpu header files.
38 #
39 INCLUDES= -nostdinc -I. -Iinclude -I$S
40 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
41 .if exists($S/../include)
42 INCLUDES+= -I$S/../include
43 .else
44 INCLUDES+= -I/usr/include
45 .endif
46
47 # This hack lets us use the Intel ACPICA code without spamming a new
48 # include path into 100+ source files.
49 .include "$S/conf/acpi.mk"
50 INCLUDES+= -I${.OBJDIR} -I"$S/${OSACPI_MI_DIR}" -I"$S/${ACPICA_DIR}/include"
51
52 # This hack lets us use the ipfilter code without spamming a new
53 # include path into 100+ source files.
54 INCLUDES+= -I$S/contrib/ipfilter
55
56 # ... and the same for Atheros HAL
57 INCLUDES+= -I$S/dev/netif/ath/hal -I$S/dev/netif/ath/hal/ath_hal
58
59 COPTS=  ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
60 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
61
62 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
63 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
64
65 DEFINED_PROF=   ${PROF}
66 .if defined(PROF)
67 CFLAGS+=        -falign-functions=16
68 .if ${PROFLEVEL} >= 2
69 IDENT+= -DGPROF4 -DGUPROF
70 PROF+=  -mprofiler-epilogue
71 .endif
72 .endif
73
74 # Put configuration-specific C flags last (except for ${PROF}) so that they
75 # can override the others.
76 CFLAGS+=        ${CONF_CFLAGS}
77
78 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
79 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
80 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
81 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
82
83 NORMAL_M= awk -f $S/tools/makeobjops.awk -- -c $<; \
84         ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
85
86 .if !defined(NO_WERROR) && (${CCVER} == "gcc41" || ${CCVER} == "gcc44")
87 WERROR=-Werror
88 .endif
89
90 GEN_CFILES= $S/platform/$P/$M/genassym.c
91 SYSTEM_CFILES= ioconf.c config.c
92 SYSTEM_SFILES= $S/platform/$P/$M/locore.s
93 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
94 SYSTEM_OBJS= locore.o ${OBJS} ioconf.o config.o hack.So
95 SYSTEM_LD= @${LD} -Bdynamic -T $S/platform/$P/conf/ldscript.$M \
96         -export-dynamic -dynamic-linker /red/herring \
97         -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
98 .if ${P} == "pc64"
99 # XXX swildner: Workaround to make kernels linked with binutils220 boot.
100 #
101 SYSTEM_LD+= -z max-page-size=1048576
102 .endif
103 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
104         ${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
105 SYSTEM_DEP+= $S/platform/$P/conf/ldscript.$M
106
107 # Normalize output files to make it absolutely crystal clear to
108 # anyone examining the build directory.
109 #
110 .if defined(DEBUG)
111 FULLKERNEL=     ${KERNEL}.debug
112 .if defined(INSTALLSTRIPPED)
113 SELECTEDKERNEL= ${KERNEL}.stripped
114 .else
115 SELECTEDKERNEL= ${KERNEL}.debug
116 .endif
117 .else
118 FULLKERNEL=     ${KERNEL}.nodebug
119 SELECTEDKERNEL= ${KERNEL}.stripped
120 .endif
121
122
123 MKMODULESENV=   MAKEOBJDIRPREFIX=${.OBJDIR} BUILDING_WITH_KERNEL=${.OBJDIR}
124 .if defined(MODULES_OVERRIDE)
125 MKMODULESENV+=  MODULES_OVERRIDE="${MODULES_OVERRIDE}"
126 .endif
127 .if defined(DEBUG)
128 MKMODULESENV+=  DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
129 .endif
130 .if defined(INSTALLSTRIPPED) || defined(INSTALLSTRIPPEDMODULES)
131 MKMODULESENV+=  INSTALLSTRIPPEDMODULES=1
132 .endif
133 MKMODULESENV+=  MACHINE_ARCH=${MACHINE_ARCH} MACHINE=${MACHINE} MACHINE_PLATFORM=${MACHINE_PLATFORM}
134