[net.micro.pc] 'make' for the IBM PC

jph (11/27/82)

Here is a short BASIC program that simulate 'make'. It will generate
a batch file of the commands necessary to recompile
those source files that have a later date than their
corresponding object files

	Jim Holtman
	harpo!whuxlb!jph
-------------------------------------------------------------

100 REM This program is similar to 'make' on UNIX(tm). It will read in the
110 REM 'auto response' file for the LINKER and look for the  source and
120 REM object files and compare the dates. If the source is later than
130 REM then object, it will generate the appropriate commands in a batch
140 REM file 'compile.bat'. Right now the program handles PASCAL and MACRO
150 REM assembler files, but can be updated for any others. The program
160 REM prompts the user for input. It requires that 4 files be open at once,
170 REM so it must be invoked:
180 REM          basic make/f:4
190 OPEN "compile.bat" FOR OUTPUT AS #3
200 OFLG = 0
210 INPUT "Link File: ",MKFILE$
220 INPUT "Listing? (y/n/lpt1/only): ",ANS$
230 IF ANS$="y" THEN LISTING$=",,;" ELSE IF ANS$="lpt1" THEN LISTING$=",,lpt1;" ELSE IF ANS$="only" THEN LISTING$=",nul,lpt1;":OFLG=1 ELSE LISTING$=";"
240 INPUT "Force compiles? (y/n): ",FORCE$
250 IF OFLG<>1 THEN INPUT "Link after compiles? (y/n): ",LINKOPT$
260 OPEN MKFILE$ FOR INPUT AS #4
270 LINE INPUT#4,LINK$
280 LINK$=LINK$+"+"
290 WHILE LEN(LINK$)>0
300     N=INSTR(LINK$,"+")
310     IF N=0 THEN PRINT "'+' not found in string":END
320     OBJ$=LEFT$(LINK$,N-1)
330     LINK$=RIGHT$(LINK$,LEN(LINK$)-N)
340     IF LEN(LINK$)=1 THEN LINE INPUT#4,LINK$:LINK$=LINK$+"+"
350     FILE$=OBJ$+".obj"
360     OPEN FILE$ FOR INPUT AS #1
370     FILE$=OBJ$+".pas"
380     ON ERROR GOTO 520
390     OPEN FILE$ FOR INPUT AS #2
400     ON ERROR GOTO 0
410     FBOBJ=VARPTR(#1)+21
420     FBSRC=VARPTR(#2)+21
430     TIMEOBJ#=((PEEK(FBOBJ+1)*256+PEEK(FBOBJ))*256+PEEK(FBOBJ+3))*256+PEEK(FBOBJ+2)
440     TIMESRC#=((PEEK(FBSRC+1)*256+PEEK(FBSRC))*256+PEEK(FBSRC+3))*256+PEEK(FBSRC+2)
450     CLOSE #1,#2
460     IF NOT((TIMESRC#>TIMEOBJ#) OR (FORCE$="y")) THEN GOTO 490
470     PRINT "Remaking: ";FILE$
480     IF RIGHT$(FILE$,3)="asm" THEN PRINT#3,"a:masm ";OBJ$;LISTING$ ELSE PRINT#3,"a:pas1 ";OBJ$;LISTING$:IF OFLG<>1 THEN PRINT#3,"a:pas2"
490 WEND
500 IF LINKOPT$="y" THEN PRINT#3,"a:link @";MKFILE$
510 SYSTEM
520 IF ERR <> 53 THEN PRINT "Unknown error -";ERR;"  Line -";ERL:RESUME 490
530 IF RIGHT$(FILE$,3)="pas" THEN MID$(FILE$,LEN(FILE$)-2,3)="asm":RESUME
540 PRINT "File not found: ";FILE$
550 CLOSE #1
560 RESUME 490