1## See sim/Makefile.am 2## 3## Copyright (C) 2005-2023 Free Software Foundation, Inc. 4## Contributed by Red Hat, Inc. 5## 6## This program is free software; you can redistribute it and/or modify 7## it under the terms of the GNU General Public License as published by 8## the Free Software Foundation; either version 3 of the License, or 9## (at your option) any later version. 10## 11## This program is distributed in the hope that it will be useful, 12## but WITHOUT ANY WARRANTY; without even the implied warranty of 13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14## GNU General Public License for more details. 15## 16## You should have received a copy of the GNU General Public License 17## along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19%C%_run_SOURCES = 20%C%_run_LDADD = \ 21 %D%/main.o \ 22 %D%/libsim.a \ 23 $(SIM_COMMON_LIBS) 24 25noinst_PROGRAMS += %D%/run 26 27## Helper targets for running make from the top-level due to run's main.o. 28%D%/%.o: %D%/%.c | %D%/libsim.a $(SIM_ALL_RECURSIVE_DEPS) 29 $(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) 30 31%C%_BUILD_OUTPUTS = \ 32 %D%/opc2c$(EXEEXT) \ 33 %D%/m32c.c \ 34 %D%/r8c.c 35 36## This makes sure build tools are available before building the arch-subdirs. 37SIM_ALL_RECURSIVE_DEPS += $(%C%_BUILD_OUTPUTS) 38 39%C%_opc2c_SOURCES = %D%/opc2c.c 40 41# These rules are copied from automake, but tweaked to use FOR_BUILD variables. 42%D%/opc2c$(EXEEXT): $(%C%_opc2c_OBJECTS) $(%C%_opc2c_DEPENDENCIES) %D%/$(am__dirstamp) 43 $(AM_V_CCLD)$(LINK_FOR_BUILD) $(%C%_opc2c_OBJECTS) $(%C%_opc2c_LDADD) 44 45# opc2c is a build-time only tool. Override the default rules for it. 46%D%/opc2c.o: %D%/opc2c.c 47 $(AM_V_CC)$(COMPILE_FOR_BUILD) -c $< -o $@ 48 49# opc2c leaks memory, and therefore makes AddressSanitizer unhappy. Disable 50# leak detection while running it. 51%C%_OPC2C_RUN = ASAN_OPTIONS=detect_leaks=0 %D%/opc2c$(EXEEXT) 52 53%D%/m32c.c: %D%/m32c.opc %D%/opc2c$(EXEEXT) 54 $(AM_V_GEN)$(%C%_OPC2C_RUN) -l $@.log $< > $@.tmp 55 $(AM_V_at)mv $@.tmp $@ 56 57%D%/r8c.c: %D%/r8c.opc %D%/opc2c$(EXEEXT) 58 $(AM_V_GEN)$(%C%_OPC2C_RUN) -l $@.log $< > $@.tmp 59 $(AM_V_at)mv $@.tmp $@ 60 61EXTRA_PROGRAMS += %D%/opc2c 62MOSTLYCLEANFILES += \ 63 $(%C%_BUILD_OUTPUTS) \ 64 %D%/m32c.c.log \ 65 %D%/r8c.c.log 66