sim: build: add basic framework for compiling arch objects in top-level
authorMike Frysinger <vapier@gentoo.org>
Tue, 27 Dec 2022 04:20:46 +0000 (23:20 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 10 Jan 2023 06:15:26 +0000 (01:15 -0500)
The code so far has been assuming that we only compile common/ objects.
Now that we're ready to compile arch-specific objects, refactor some of
the flags & checks a bit to support both.

sim/Makefile.am
sim/Makefile.in
sim/common/defs.h
sim/common/local.mk

index e47244d7b8dd3443f1d015d38f08ffbe3a871fd7..3c46925976f3c2552899af33a917046c153b46b8 100644 (file)
@@ -41,15 +41,27 @@ BUILT_SOURCES =
 CLEANFILES =
 DISTCLEANFILES =
 MOSTLYCLEANFILES = core
-
-AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)
+## We build some objects ourselves directly that Automake doesn't track, so
+## make sure all objects in subdirs get cleaned up.
+MOSTLYCLEANFILES += $(SIM_ENABLED_ARCHES:%=%/*.o)
+
+AM_CFLAGS = \
+       $(WERROR_CFLAGS) \
+       $(WARN_CFLAGS) \
+       $(AM_CFLAGS_$(subst -,_,$(@D))) \
+       $(AM_CFLAGS_$(subst -,_,$(@D)_$(@F)))
 AM_CPPFLAGS = \
        $(INCGNU) \
+       -I$(srcroot) \
        -I$(srcroot)/include \
        -I../bfd \
        -I.. \
+       -I$(@D) \
+       -I$(srcdir)/$(@D) \
        $(SIM_HW_CFLAGS) \
-       $(SIM_INLINE)
+       $(SIM_INLINE) \
+       $(AM_CPPFLAGS_$(subst -,_,$(@D))) \
+       $(AM_CPPFLAGS_$(subst -,_,$(@D)_$(@F)))
 
 AM_CPPFLAGS_FOR_BUILD = \
        -I$(srcroot)/include \
index 839e6e17e273276eb69cc1131ed9d60130fb3a9d..6f2042a3523179f26b23a32bf30a4c21f14b8ba6 100644 (file)
@@ -1789,7 +1789,8 @@ CLEANFILES = common/version.c common/version.c-stamp \
        testsuite/common/bits32m31.c testsuite/common/bits64m0.c \
        testsuite/common/bits64m63.c
 DISTCLEANFILES = $(am__append_100)
-MOSTLYCLEANFILES = core $(common_HW_CONFIG_H_TARGETS) $(patsubst \
+MOSTLYCLEANFILES = core $(SIM_ENABLED_ARCHES:%=%/*.o) \
+       $(common_HW_CONFIG_H_TARGETS) $(patsubst \
        %,%/stamp-hw,$(SIM_ENABLED_ARCHES)) \
        $(common_GEN_MODULES_C_TARGETS) $(patsubst \
        %,%/stamp-modules,$(SIM_ENABLED_ARCHES)) $(am__append_7) \
@@ -1799,10 +1800,16 @@ MOSTLYCLEANFILES = core $(common_HW_CONFIG_H_TARGETS) $(patsubst \
        $(am__append_71) $(am__append_77) $(am__append_83) \
        $(am__append_99) $(am__append_106) $(am__append_115) \
        $(am__append_130) $(am__append_135)
-AM_CFLAGS = $(WERROR_CFLAGS) $(WARN_CFLAGS)
-AM_CPPFLAGS = $(INCGNU) -I$(srcroot)/include -I../bfd -I.. \
-       $(SIM_HW_CFLAGS) $(SIM_INLINE) -I$(srcdir)/common \
-       -DSIM_COMMON_BUILD
+AM_CFLAGS = \
+       $(WERROR_CFLAGS) \
+       $(WARN_CFLAGS) \
+       $(AM_CFLAGS_$(subst -,_,$(@D))) \
+       $(AM_CFLAGS_$(subst -,_,$(@D)_$(@F)))
+
+AM_CPPFLAGS = $(INCGNU) -I$(srcroot) -I$(srcroot)/include -I../bfd \
+       -I.. -I$(@D) -I$(srcdir)/$(@D) $(SIM_HW_CFLAGS) $(SIM_INLINE) \
+       $(AM_CPPFLAGS_$(subst -,_,$(@D))) $(AM_CPPFLAGS_$(subst \
+       -,_,$(@D)_$(@F))) -I$(srcdir)/common -DSIM_TOPDIR_BUILD
 AM_CPPFLAGS_FOR_BUILD = -I$(srcroot)/include $(SIM_HW_CFLAGS) \
        $(SIM_INLINE) -I$(srcdir)/common
 COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
@@ -1818,6 +1825,7 @@ SIM_ALL_RECURSIVE_DEPS = common/libcommon.a \
 SIM_INSTALL_DATA_LOCAL_DEPS = 
 SIM_INSTALL_EXEC_LOCAL_DEPS = $(am__append_43)
 SIM_UNINSTALL_LOCAL_DEPS = $(am__append_44)
+AM_CPPFLAGS_common = -DSIM_COMMON_BUILD
 common_libcommon_a_SOURCES = \
        common/callback.c \
        common/portability.c \
index bbaee4ebd0ce4847eed3e14646ed2ac8010c3057..0f4062c2031dc2ca4b0ddf0da657f0d6d138682b 100644 (file)
@@ -35,7 +35,7 @@
 #undef PACKAGE_VERSION
 
 /* Include common sim's various configure tests.  */
-#ifndef SIM_COMMON_BUILD
+#ifndef SIM_TOPDIR_BUILD
 #include "../config.h"
 #else
 #include "config.h"
index debb55da933ba2d8aaa2d6f26ca5c0e9369b63b6..32b5db6a6eea1cae160a7f057bd4260f8ae9af46 100644 (file)
@@ -20,7 +20,8 @@
 
 AM_CPPFLAGS += \
        -I$(srcdir)/%D% \
-       -DSIM_COMMON_BUILD
+       -DSIM_TOPDIR_BUILD
+AM_CPPFLAGS_%C% = -DSIM_COMMON_BUILD
 AM_CPPFLAGS_FOR_BUILD += -I$(srcdir)/%D%
 
 ## This makes sure common parts are available before building the arch-subdirs