17 August 2023, 21:16 | #1 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 188
|
Question about smake Transformation Rules and separate object-directory.
Edit: Never mind, I solved it. I was editing the wrong file. The solution was to add "OBJECTNAME=myassign:my/obj/dir/" to SCOPTIONS, and remove the "$(OBJDIR)" I put in smakefile.
Edit2: I celebrated too early, see next post. I'm trying to stop my compiles from cluttering the source directory with binaries. But hit a snag with one smakefile. It started out like this(irrelevant parts removed and filenames changed for brevity): Code:
OBJS = file1.o file2.o ... file42.o all: mylibrary.library ... mylibrary.library: $(OBJS) slink with lib:utillib.with with << define __ctype=___ctype libprefix _L_ libfd my_lib.fd from lib:libent.o lib:libinit.o $(OBJS) to mylibrary.library lib lib:sc.lib lib:pools.lib lib:amiga.lib lib:asyncio.lib $(DEBUGLIB) libversion $(LIBVER) librevision $(LIBREV) noicons maxhunk 51200 sc sd < .c.o: sc $*.c Code:
OBJDIR = myassign:my/obj/dir/ BINDIR = myassign:my/bin/dir/ OBJS = $(OBJDIR)file1.o $(OBJDIR)file2.o ... $(OBJDIR)file42.o all: $(BINDIR)mylibrary.library ... $(BINDIR)mylibrary.library: $(OBJS) slink with lib:utillib.with with << define __ctype=___ctype libprefix _L_ libfd my_lib.fd from lib:libent.o lib:libinit.o $(OBJS) to $(BINDIR)mylibrary.library lib lib:sc.lib lib:pools.lib lib:amiga.lib lib:asyncio.lib $(DEBUGLIB) libversion $(LIBVER) librevision $(LIBREV) noicons maxhunk 51200 sc sd < .c.o: sc $*.c Code:
SMAKE (line 61): Missing file, target, or action for myassign:my/obj/dir/file1.o Code:
$(BINDIR)mylibrary.library: $(OBJS) Code:
$(objdir)file1.o: file1.c -Hagbard Celine Last edited by hceline; 17 August 2023 at 22:30. Reason: Too soon. |
17 August 2023, 22:29 | #2 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 188
|
I just almost got it. Back to original smakefile and added this to SCOPTIONS:
Code:
OBJECTNAME=myassign:my/obj/dir/ Code:
slink with lib:utillib.with with temp_smk.tmp Slink - Version 6.59 Copyright (c) 1988-1995 SAS Institute, Inc. All Rights Reserved. Error 426: Cannot find object file1.o slink failed returncode 140 Last edited by hceline; 17 August 2023 at 22:46. Reason: Part of linker error was missing: added. |
27 August 2023, 22:55 | #3 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 188
|
|
20 September 2023, 14:19 | #4 |
Registered User
Join Date: Nov 2010
Location: Grenoble, Isère, Rhône-Alpes, France, Europe, Earth
Posts: 298
|
look at this (use google translate if you don't understand french)
https://gilles-pelletier-vft.go.yj.f...c_makefile.htm makefiles will no longer hold any secrets for you |
28 September 2023, 16:18 | #5 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 188
|
Thanks for the link. It was a good example. But sadly it was virtually identical to my first attempt. And thus gave the same result.
But I have been thinking abut this, OBJECTNAME in SCOPTIONS works when sc starts slink. So the thing missing is how this is done. I think I must re-read the manual / find an undocumented switch/variable/something. |
29 September 2023, 09:15 | #6 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 690
|
You have to use make or use arexx as a workaround:
Use a template and modify this with arexx then execute the modifed smakefile. Example: define the objects and the workdir in the smakefile Code:
.PHONY: all OBJ = a b c all: rx fe.rexx workdir/ $(OBJ) smake -f smakefile.tmp Code:
.PHONY: all OBJ = #OBJ# SRC = #SRC# LIBS = LIB:sc.lib lib:scm.lib all: prog prog: $(OBJ) slink from LIB:c.o $(OBJ) to prog LIB $(LIBS) #TRG# fe.rexx Code:
/* smake support */ ARG dir o obj = "" src = "" trg = "" DO WHILE LENGTH(o) > 0 PARSE VAR o a o obj = obj || dir || a || ".o" || " " src = src || dir || a || ".c" || " " trg = trg || dir || a || ".o: " || dir || a || ".c" || '0d'x || '0a'x || '09'x || "sc $(SCOPTS) OBJNAME=$*.o $*.c" || '0d'x || '0a'x END OPEN('sfile', "smakefile.sub", 'R') content = READCH('sfile', 65536) CALL CLOSE('sfile') CALL patch(content, "#OBJ#", obj) CALL patch(content, "#SRC#", src) CALL patch(content, "#TRG#", trg) OPEN('sfile', "smakefile.tmp", 'W') CALL WRITECH('sfile', content) CALL CLOSE('sfile') EXIT patch: ARG content, what, repl i = INDEX(content, what) IF i > 0 THEN content = SUBSTR(content, 1, i - 1) || repl || SUBSTR(content, i + LENGTH(what)) ENDIF RETURN Last edited by bebbo; 29 September 2023 at 10:16. |
10 October 2023, 15:04 | #7 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 188
|
Thank you for a working solution. In the meantime, I have come to the realization that the correct approach would be to generate the targets in question with a dependency-scanner.
So I think I'd rather try to do that. |
06 November 2023, 10:14 | #8 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 188
|
An update, in case someone has the same issue and finds this thread.
I could not find a dependency-scanner that accepted ".o" files on command-line and worked with any codebase. So I ported and modified latest makedepend from Xorg: http://aminet.net/package/dev/c/makedepend_AmiMod WARNING (which was unfortunately missing in original upload): The stack usage is dependent on organization of the files it is parsing. The binary is compiled without stackcheck/stackextend, and will crash hard if it runs out of stack. Final Edit(hopefully): I feel very stupid. I had several versions of the script, only one working. And used one of the non-working ones when making this post. I have now replaced it with the working version. I had also forgotten that "modified" was needed on sc commandline for this to work. Also, just before I realized I should use a dependency-scanner, I found a another working solution: Edit: I made a brainfart when first posting this. it will only work if you use Code:
OBJECTNAME=myassign:my/obj/dir/ It will not work with translation rule Code:
.c.o: sc $*.c objname $@ Change the link command and transformation rule in smakefile like this: Code:
OBJDIR = myassign:my/obj/dir/ BINDIR = myassign:my/bin/dir/ OBJS = file1.o file2.o ... file42.o all: $(BINDIR)mylibrary.library ... $(BINDIR)mylibrary.library: $(OBJS) cdlink $(OBJDIR) with lib:utillib.with with << define __ctype=___ctype libprefix _L_ libfd my_lib.fd from lib:libent.o lib:libinit.o $(OBJS) to $(BINDIR)mylibrary.library lib lib:sc.lib lib:pools.lib lib:amiga.lib lib:asyncio.lib $(DEBUGLIB) libversion $(LIBVER) librevision $(LIBREV) noicons maxhunk 51200 sc sd < .c.o: sc $*.c modified objname myassign:my/obj/dir/ Code:
.key OBJDIR/A,ARGUMENTS/F ; $VER: cdlink 1.1 (10.10.2023) ; Break smake no ChangeDirectory rule and link directly from objdir set echo on FailAt 21 Set ORGDIR `cd` Set LINKFILE temp_smk.tmp CD <OBJDIR> IF EXISTS $ORGDIR/$LINKFILE MakeLink $LINKFILE $ORGDIR/$LINKFILE EndIF slink <ARGUMENTS> IF EXISTS $LINKFILE Delete $LINKFILE EndIF FailAt 10 Last edited by hceline; 06 November 2023 at 15:01. Reason: Multi Brainfart |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compile directory, work directory and relative paths | phx | Coders. Asm / Hardware | 13 | 25 July 2022 15:31 |
Polygon transformation problem | TCH | Coders. General | 4 | 07 March 2020 15:20 |
Rules | BippyM | project.Sprites | 3 | 20 April 2005 09:59 |
Rules | RCK | project.WHDLoad | 0 | 02 October 2004 14:45 |
|
|