Pergunta

On an IBM i system, using PASE (AIX emulator), i try to compile RPG sources using a makefile.

I have RPG sources and try to build a PGM program. Every single source will be compile in a distinct PGM.

Here is the syntax i tried first

VPATH=.
SYSTEM=system -iv
CRTRPGMOD=CRTRPGMOD
BIN_LIB=MR_CH
CURRENT_PATH=/currentPath #${PWD} doesn't work

#With this line active, it works
SRC_RPGLE = src1.rpgle src2.rpgle
#With this line active, it doesn't work
#SRC_RPGLE = $(shell echo *.rpgle) #Should list every sources i want to compile
TARGETS   = $(SRC_RPGLE:.rpgle=.rpgleMod) #Should list every program i want to build

.SUFFIXES: .rpgle .rpgleMod

.rpgle.rpgleMod:
    $(SYSTEM) "$(CRTRPGMOD) MODULE($(BIN_LIB)/$(*F)) SRCSTMF('$(CURRENT_PATH)/$<')" > $(*F)_1_crtrpgmod.log
    ln -fs $(*F).rpgMod

all: $(TARGETS)

I tried to apply GNU shell syntax using AIX make command

Any suggestions ?

Foi útil?

Solução

I'm not familiar with the AIX implementation of make but assuming that the linked man page is all there is to it, then it looks like a bare-bones implementation of POSIX make (for an older POSIX spec).

Therefore, the only way to do what you want (expand a list of files) is to use recursion, so that you get access to the shell, like this:

SYSTEM=system -iv
CRTRPGMOD=CRTRPGMOD
BIN_LIB=MR_CH
CURRENT_PATH=/currentPath
CURRENT_PATH=/home/CHARLES/Projets/MRSRC/tmp

recurse:
        $(MAKE) all SRC_RPGLE="`echo *.rpgle`"

TARGETS   = $(SRC_RPGLE:.rpgle=.rpgleMod)

.SUFFIXES: .rpgle .rpgleMod

.rpgle.rpgleMod:
        $(SYSTEM) "$(CRTRPGMOD) MODULE($(BIN_LIB)/$(*F)) SRCSTMF('$(CURRENT_PATH)/$<')" > $(*F)_1_crtrpgmod.log
        ln -fs $(*F).rpgMod

all: $(TARGETS)

The recurse rule MUST be the first target in the makefile. Also this won't help if you want to run other targets like make foobar; it will only help you run all properly.

Alternatively you can obtain GNU make and build it for your system, and use that. In the end that might be a more straightforward approach.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top