The make file is not a shell script. This is the configuration file for the expert system. In particular, an expert system that knows if you tell how to efficiently create files and their dependencies with a minimum of re-creating files that are not needed to be redone.
If you look at the first rule you have:
myProgram: main.o addSorted.o freeLinks.o gcc -lm -o myProgram main.o addSorted.o freeLinks.o
which tells the system how to make a file called myProgram if it decides what to do. Parts after the colon are the files that I need. If they are not there or decide that they are out of date, make will try to find some recipe that can be used to create or update. once everything is done, then it will execute the line "gcc ..." and assume that it will create or update myProgram.
The ar and ranlib lines that you do not match the required syntax for the makefile rule. In appearance, they seem to be a recipe for creating libmylib.a. If you put them in the syntax, make should say what you get:
libmylib.a: main.o addSorted.o freeLinks.o ar rcu libmylib.a main.o addSorted.o freeLinks.o ranlib libmylib.a
myProgram should depend on the library itself, and not on the contents of the library, and it is best to place the library parameters at the end:
myProgram: libmylib.a gcc -o myProgram libmylib.a -lm
if you want, you can use the gcc option to search for libraries in the current directory:
gcc -L. -o myProgram main.o -lmylib -lm
There are also makefile variables that can help you not to repeat so I would write the first rule as:
myProgram: libmylib.a gcc -L. -o $@ -lmylib -lm
however, it is unlikely that main.o should really be part of the library, like so:
myProgram: main.o libmylib.a gcc -L. -o $@ $< -lmylib -lm
and library rule:
libmylib.a: addSorted.o freeLinks.o ar rcu $@ $+ ranlib $@
$ + here means "all dependency file names."
Finally, if you want gcc to make the actual static executable, and not just use the library you created, you need to pass the -static option to gcc.